<template>
  <div>
       <br/>
       <div>
      <el-form  :inline="true" :model="A">
            <el-form-item prop="" label="医院名称：">
                <el-input v-model="A.campusName" placeholder="医生姓名"  ></el-input>
            </el-form-item>
            <el-form-item label="科室名称：">
                   <el-select v-model="A.divisionName" placeholder="请选择" style="width: 200px" >
                    <el-option
                    v-for="item in options"
                    :key="item.id"
                    :label="item.divisionName"
                    :value="item.divisionName">
                    </el-option>
                </el-select>
              </el-form-item>
            <el-form-item>
                <el-button type="success" icon="el-icon-search" @click="Depmhc()"></el-button>
            </el-form-item>
            
            <el-button type="primary" style="margin-left: 300px" @click="tiajia()">添加科室信息</el-button>
        </el-form>
    </div>
      <div>
        
      </div>
      <div>
              <el-table border :data="Data.slice((currentPage-1)*pagesize,currentPage*pagesize)">
              <el-table-column prop="divisionName" label="科室名称" ></el-table-column>
              <el-table-column prop="campusName" label="院区名称"  ></el-table-column>
              <el-table-column prop="divisionIdentify" label="科室标识" ></el-table-column>
              <el-table-column prop="floorDirectory" label="楼层索引"  ></el-table-column>
              <el-table-column prop="createTime" label="科室时间"  ></el-table-column>
              <el-table-column label="操作"  v-slot="a">
              <el-button type="primary" size="mini" @click="xiugai(a.row)">修改</el-button>
              <el-button type="primary" size="mini" @click="shanchu(a.row)">删除</el-button>
            </el-table-column>
          </el-table>
           <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[3, 5, 7]"
                :page-size="pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="Data.length">
        </el-pagination>
      </div>
      <div>
      <el-dialog title="是否删除" :visible.sync="delmtk" :model="del">
        <el-button type="primary" @click="delDeparment()">确定</el-button>
        <el-button type="primary" @click="delmtk=false" >取消</el-button>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
    data(){
        return{
            A:{campusName:'',divisionName:''},
            options:[],
            Data:[],
            upd: {},
            del: {},
            delmtk: false,
            headertitle: "",
            centerDialogVisible:false,
            pagesize:3,
            currentPage:1,
        }
    },
    created(){
        this.findDivisionAll()
        this.option();
    },
    methods:{
        option(){
            this.$axios.get("/user/user/doctor/ren/findDivisionAll").then(res=>{
              console.log(res.data.data.list)
                this.options=res.data.data.list
            })
        },
        findDivisionAll(){
            this.$axios.get("/user/user/doctor/ren/findDivisionAll").then(res=>{
              console.log(res.data.data.list)
                this.Data=res.data.data.list
            })
        },
        tiajia(){
            this.$router.push({ path: "/AddDepartment" });
        },
        xiugai(row){
            console.log(row);
            this.$router.push({path: "/UpdDepartment",query: {row: row}});
            this.upd = { ...row };
        },
        shanchu(row){
            this.delmtk=true;
            this.del = { ...row };
        },
        delDeparment(){
            this.$axios.post("/user/user/doctor/ren/delDepartment",this.del).then(res=>{
            this.delmtk=false;
            this.findDivisionAll();
     })
   },
        Depmhc(){
            this.$axios.get("/user/user/doctor/ren/Depmhc",
            {  	params:{
                campusName:this.A.campusName,
                divisionName:this.A.divisionName, }}).then(res=>{
                this.Data = res.data.data.list;
                })
   
        },
         handleSizeChange(size) {
            this.pagesize = size;
      },
       handleCurrentChange(currentPage) {
            this.currentPage = currentPage;
      }
    }
}
</script>

<style>

</style>
